﻿using System;
using System.Threading.Tasks;

namespace Sidvall.Devices.Uwp
{
    public class GeolocatorFactory : IGeolocatorFactory
    {
        #region Public Members

        #region CreateGeolocatorAsync

        public async Task<IGeolocator> CreateGeolocatorAsync()
        {
            var status = await Windows.Devices.Geolocation.Geolocator.RequestAccessAsync();
            switch (status)
            {
                case Windows.Devices.Geolocation.GeolocationAccessStatus.Allowed:
                    var item = new Windows.Devices.Geolocation.Geolocator();
                    return new Geolocator(item);
                default:
                    return null;
            }
        }

        #endregion
        #region ToString

        public override string ToString()
        {
            return "GeolocatorFactory - UWP";
        }

        #endregion

        #endregion
    }
}
